/* Copyright  2009
   @Author
   Richard Changde Yin            e-mail yinchangde@hotmail.com

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; version 2 of the License.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

/*
** @filename : <field/num.h>
*
*/
#ifndef _SERVER_FIELD_NUM_H
#define _SERVER_FIELD_NUM_H

class Field_num :public Field {

public:
  const uint8_t dec;
  bool decimal_precision;       // Purify cannot handle bit fields & only for decimal type
  bool unsigned_flag;           // Purify cannot handle bit fields
  Field_num(unsigned char *ptr_arg,uint32_t len_arg, unsigned char *null_ptr_arg,
            unsigned char null_bit_arg, utype unireg_check_arg,
            const char *field_name_arg,
            uint8_t dec_arg, bool zero_arg, bool unsigned_arg);

  Item_result result_type () const { return REAL_RESULT; }

  friend class Create_field;
  void make_field(Send_field *);
  inline uint32_t decimals() const { return (uint32_t) dec; }
  inline uint32_t size_of() const { return sizeof(*this); }
  bool eq_def(Field *field);
  int store_decimal(const db_decimal *);
  db_decimal *val_decimal(db_decimal *);
  /// field.h

  uint32_t is_equal(Create_field *new_field);

  int check_int(const CHARSET_INFO * const cs, const char *str, int length,
                const char *int_end, int error);

  bool get_int(const CHARSET_INFO * const cs, const char *from, uint32_t len,
               int64_t *rnd, uint64_t unsigned_max,
               int64_t signed_min, int64_t signed_max);
};


#endif //_SERVER_FIELD_NUM_H
